package com.carleasoft.mps.cms.business.education.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.carleasoft.mps.cms.business.education.bean.entity.EducationEntity;
import com.carleasoft.mps.cms.business.education.bean.entity.EducationCollectEntity;
import com.carleasoft.mps.cms.business.education.bean.po.EducationDoorPagePo;
import com.carleasoft.mps.cms.business.education.bean.po.EducationPageQueryPo;
import com.carleasoft.mps.cms.business.education.bean.vo.EduDoorVo;
import com.carleasoft.mps.cms.business.education.bean.vo.EduDoorListVo;
import com.carleasoft.mps.cms.business.education.bean.vo.EduPageQueryVo;
import com.carleasoft.mps.cms.business.education.bean.vo2.EduVo;
import com.carleasoft.mps.cms.business.education.service.EduDoorService;
import com.carleasoft.mps.cms.business.message.bean.po.MessageNotePageQueryPo;
import com.carleasoft.mps.cms.business.message.bean.vo.MessageNoteVo;
import com.carleasoft.mps.cms.business.message.service.MessageNoteService;
import com.carleasoft.mps.core.result.R;
import com.carleasoft.mps.core.utils.IBeanUtil;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @author: yangHao
 * @createDate:2023/5/23
 * @description:
 */
@RestController
@RequestMapping("/edu/door")
public class EduDoorController {
    @Autowired
    private MessageNoteService messageNoteService;
    @Autowired
    private EduDoorService eduDoorService;

    /**
     * 门户-信件公开-分页查询
     */
    @PostMapping("/massageNotePageQuery")
    public R<Page<MessageNoteVo>> pageQuery(@RequestBody MessageNotePageQueryPo messageNotePageQueryPo) {
        return R.ok(messageNoteService.pageQuery1(messageNotePageQueryPo));
    }

    /**
     * 门户-教学资源八库各种类型
     *
     * @param educationDoorPagePo
     * @return
     */
    @PostMapping("/doorList")
    public R doorList(@RequestBody EducationDoorPagePo educationDoorPagePo) {
        List<EduDoorListVo> eduDoorListVos = eduDoorService.doorList(educationDoorPagePo);
        return R.ok(eduDoorListVos);
    }

    /**
     * 门户-教学资源八库
     *
     * @return
     */
    @PostMapping("/doorEducation")
    public R doorEducation() {
        List<EduDoorVo> eduDoorVos = eduDoorService.doorEducation();
        return R.ok(eduDoorVos);
    }


    /**
     * 门户-教育资源所有信息
     *
     * @return
     */
    @PostMapping("/getEduInfo")
    public R getEduInfo(@RequestBody EducationDoorPagePo educationDoorPagePo) {
        List<EduVo> eduDoorVos = eduDoorService.getEduInfo(educationDoorPagePo);
        return R.ok(eduDoorVos);
    }


    /**
     * 门户教学资源八库-分页
     *
     * @param educationPageQueryPo
     * @param request
     * @return
     */
    @PostMapping("/doorPageQuery")
    public R doorPageQuery(@RequestBody EducationPageQueryPo educationPageQueryPo, HttpServletRequest request) {
        Page<EduPageQueryVo> educationPageQueryVoPage = eduDoorService.doorPageQuery(new Page(educationPageQueryPo.getCurrent(), educationPageQueryPo.getSize()), educationPageQueryPo, request);
        return R.ok(educationPageQueryVoPage);
    }

    /**
     * 查询所属库列表
     *
     * @return
     */
    @PostMapping("/getEducation")
    public R getEducation() {
        List<EducationEntity> libraryEntities = eduDoorService.getEducation();
        return R.ok(libraryEntities);
    }

    /**
     * 根据所属库编码查询分类
     *
     * @param educationEntity
     * @return
     */
    @PostMapping("/getCategory")
    public R getCategory(@RequestBody EducationEntity educationEntity) {
        IBeanUtil.paramVerify(educationEntity, "educationCode");
        List<EducationCollectEntity> eduCollectEntities = eduDoorService.getCategory(educationEntity);
        return R.ok(eduCollectEntities);
    }

}
